package stark.app.function.view.photomodelview;

import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder;

import org.jetbrains.annotations.NotNull;

import stark.app.R;
import stark.app.databinding.ItemPmvModelBinding;
import stark.common.basic.adapter.BaseDBRVAdapter;

/**
 * Author：daizhongbin on 2021/7/29
 * Email：1027154338@qq.com
 * Desc:
 */
public class PhotoModelViewAdapter extends BaseDBRVAdapter<Integer, ItemPmvModelBinding> {

    private int selPos = 0;

    public PhotoModelViewAdapter() {
        super(R.layout.item_pmv_model, 0);
    }

    @Override
    public void onBindViewHolder(@NotNull BaseDataBindingHolder<ItemPmvModelBinding> holder, int position) {
        super.onBindViewHolder(holder, position);
        holder.getDataBinding().ivImg.setSelected(selPos == position);
    }

    @Override
    protected void convert(@NotNull BaseDataBindingHolder<ItemPmvModelBinding> holder, Integer integer) {
        ItemPmvModelBinding binding = holder.getDataBinding();
        binding.ivImg.setImageResource(integer);
    }

    public void setSelPos(int selPos) {
        if (this.selPos != selPos) {
            this.selPos = selPos;
            notifyDataSetChanged();
        }
    }
}
